<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>访客管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/3rd/X-admin/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/3rd/X-admin/css/xadmin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/3rd/X-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/3rd/X-admin/js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>登录帐号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="account" name="account" value="${admin.account}" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="passwd" class="layui-form-label">
                    <span class="x-red">*</span>登录密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="passwd" name="passwd" value="${admin.passwd}" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>姓名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name"  value="${admin.name}" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                </label>
                <input name="id" id="id" value="${admin.id}" type="hidden">
                <button  class="layui-btn" lay-filter="add" lay-submit="" style="    margin-left: 100px;">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        form.on('submit(add)',
            function(data) {
                var datas={name:$("#name").val(),account:$("#account").val()
                    ,passwd:$("#passwd").val(),id:$("#id").val()
                };
                $.post("${pageContext.request.contextPath}/adminManager/updateAdmin", datas, function (data) {
                    var result=eval(data);
                    console.log(data);
                    if (result.status==300) {
                        layer.alert("修改失败，帐号已经存在", {icon: 5});
                    }else if (result.status==200) {
                        layer.alert("修改成功", {icon: 6 },
                            function() {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                xadmin.father_reload();
                            });
                    } else {
                        layer.alert("修改失败", {
                                icon: 5
                            },
                            function() {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                    }
                });
                return false;
            });

    });
</script>
</body>

</html>
